<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>测试页面</title>
    <script src="./js/jquery-3.6.0.min.js"></script>
</head>
<body>
<form action="">
    UserName: <input type="text" id="us">
    password: <input type="text" id="pw">
    operationCode: <input type="text" name="" id="op">
    ip: <input type="text" value="localhost" id="ip">
    port: <input type="text" value="8080" id="port">
    uri: <input type="text" value="OperationServlet" id="uri">
    points: <input type="text" value="" id="points">
    status: <input type="text" value="" id="status">
    <input type="button" value="测试" id="btn" onclick="">
</form>
    <pre>
        你好：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=1
        我们是好朋友了：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=2
        可以：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=3
        不行：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=4
        好的：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=5
        不客气：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=6
        叔叔早上好：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=7
        老师早上好：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x01&Payload=8
        拥抱：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x02&Payload=1
        举手：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x02&Payload=2
        坐下：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x02&Payload=3
        伸手：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x02&Payload=4
        走路：http://101.34.9.187:8080/MedicalGame/OperationCode?ID=0x02&Payload=5
    </pre>
</body>
<script>
    $(function() {
        $("#btn").click(() => {
            let data = {
                "userName":$('#us').val(),
                "password":$('#pw').val(),
                "operationCode":$('#op').val(),
                "points":$('#points').val(),
                "status":$('#status').val(),
            }
            let ip = $('#ip').val();
            let port = $('#port').val();
            let uri = $('#uri').val();
            $.ajax({
                type: "post",
                url: "http://" + ip + ":"+ port +"/"+uri,
                data: JSON.stringify(data),
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (responseText) {
                    window.console.log(responseText);
                    alert("成功" + JSON.stringify(responseText));
                },
                error: function () {
                    alert("数据丢失");
                },
            });
        })
    });
</script>
</html>